<?php
namespace Home\Controller;
use Think\Controller;
class CallBackController extends BaseController {

	/**
	 * @desc: 中通注册回调接口（参考中通对接开发文档）
	 * @Author: delayhsiao
	 * @update: 2016-12-21
	 **/
	public function ztRegisterCallback(){
		$data = file_get_contents("php://input");
        file_put_contents('ztRegisterCallback.txt',json_encode( $data ) . "\n" , FILE_APPEND );
		$data_arr = explode('&',$data);
		foreach($data_arr as $k => $v){
			$tmp = explode('=',$v);
			if($tmp[0]=='data'){
				$facilityArr = json_decode(urldecode($tmp[1]),true);
				break;
			}
		}

		$facilityNo = $facilityArr['facilityNo'];

        //切割站点编号
		$where = array('f_station_id'=>substr($facilityNo,4,strlen($facilityNo)-1),'f_com_id'=>125);

		//修改审核状态
        $update_map = array(
            'f_status'          => '1',
            'f_org_name'        => $facilityArr['confSite'],
            'f_success_time'    => date('YmdHis')
        );

		$result = D('tp_station_register')->where( $where )->save( $update_map );

		if($result!==false){
			$return = array(
				'status' => true,
				'reason' => '接收成功'
			);
		}else{
			$return = array(
				'status' => false,
				'reason' => '更新注册状态失败'
			);
		}
		$this->ajaxReturn($return);
	}

}